//js/common.js
/**
 * 验证权限
 * @param {} code
 */
function commonHasAuthCode(code) {
  var user = sessionStorageClient.getJSON("user");
  if (user == null || !user.authMinus) {
    return false;
  }
  var checkList = function(list, code) {
    var checkedFlag = false;
    for (var i = 0; i < list.length; i++) {
      var item = list[i];
      if (item && item.taskCode == code) {
        checkedFlag = true;
        break;
      }
      if (item.children && item.children.length > 0) {
        checkedFlag = checkList(item.children, code);
      }
      if (checkedFlag) {
        break;
      }
    }
    return checkedFlag;
  };
  var flag = checkList(user.authMinus, code);
  return flag;
}
function commonVerifyAuthCode(success) {
  var user = sessionStorageClient.getJSON("user");
  if (user != null) {
    success && success();
    return;
  }
  var serverUrl = App.serverUrl + "merchantApp/index/queryUserData.do";
  var sucFunc = function(result) {
    if (String(result.success) == "true") {
      sessionStorageClient.putJSON("user", result.resultObject);
      success && success();
    }
  };

  var failFunc = function() {

  };
  CommonUtil.sendJsonpRequest({
    url: serverUrl,
    success: sucFunc,
    error: failFunc,
    useDefaultLoading: false
  });
};
//** 处理URL地址，判断是是完整url，非完整url增加http://p.
function commonActionYunzongUrl(url){
  if(url.indexOf('http')>-1){
    return url;
  }
  return App.previewUrlPrefix + url;
}
